package light.head.dao.oa;

import java.util.List;

import org.springframework.stereotype.Service;

import light.head.framework.base.BaseDAO;
import light.head.model.ReturnDetail;
/***
 * 物品归还（标签）详情
 * @author yy
 *
 */
@Service
public class ReturnDetailDAO extends BaseDAO<ReturnDetail, Integer>{

	
	
	/**
	 * 
	 * @param cdCodes
	 * @return
	 */
	public List<ReturnDetail> findByConCodes(List<Object> cdCodes) {
		if (null == cdCodes || cdCodes.size() == 0) return null;
		
		StringBuffer hql = new StringBuffer(" FROM ReturnDetail detail WHERE detail.ric IN (");
		for (int i = 0; i < cdCodes.size(); i++) {
			hql.append("?,");
		}
		hql.deleteCharAt(hql.length() - 1).append(")");
		return find(hql.toString(), null, null, cdCodes.toArray());
	}
	
	/**
	 * 通过返还信息表的编号获取所有详情
	 * @param rcode 返回信息表编号
	 */
	public List<ReturnDetail> findByRCode(Integer rcode) {
		if (null == rcode) return null;
		StringBuffer hql = new StringBuffer("FROM ReturnDetail detail WHERE detail.ric IN (SELECT r.code FROM ReturnItem r WHERE r.rc = ?)");
		return find(hql.toString(), null, null, rcode);
	}
}
